<?php
    /**
    * Email : mr.linhtx88@gmail.com   
    * Phone : +84919.021.508
    * 
    * History       :
    *   Date        : 15-Apr-2012
    *   Modified by : mr.linhtx88@gmail.com        
    *   Purpose     : create class bllStory, function getLatest
    */

    include_once("./Library/DataProvider/Story/dalStory.php");    
    include_once("./Library/Utility/utility.php"); 

    class bllStory{     
        public function getLatestStory($forumid){  
            $forumid = utility::CheckInput($forumid);  
            
            $query = "select p.pagetext, t.title 
            from post p, thread t
            where p.threadid=t.threadid
            and t.forumid = ".$forumid."
            order by p.threadid desc
            limit 1"; 
            // return
            return dalStory::getLatestStory($query); 
        }   

        public function getTopStory_1($forumid){       
            $forumid = utility::CheckInput($forumid);

            $query = "select p.pagetext, t.title, p.threadid
            from post p, thread t
            where p.threadid=t.threadid
            and t.forumid = ".$forumid."
            order by p.threadid desc
            limit 1"; 
            // return
            return dalStory::getTopStory_1($query); 
        }         

        public function getTopStory_2($forumid){  
            $forumid = utility::CheckInput($forumid);  
            
            $query = "select p.pagetext, t.title, p.threadid
            from post p, thread t
            where p.threadid=t.threadid
            and t.forumid = ".$forumid."
            order by p.threadid desc
            limit 2"; 
            // return
            return dalStory::getTopStory_2($query); 
        }    

        public function getTopStory_3($forumid){  
            $forumid = utility::CheckInput($forumid);  
            
            $query = "select p.pagetext, t.title, p.threadid
            from post p, thread t
            where p.threadid=t.threadid
            and t.forumid = ".$forumid."
            order by p.threadid desc
            limit 3"; 
            // return
            return dalStory::getTopStory_3($query); 
        }     
    }   
?>
